package com.zwj.controller;


import com.zwj.bo.*;
import com.zwj.entity.UserEntity;
import com.zwj.service.ClassBaseInfoService;
import com.zwj.utils.TokenUtils;
import com.zwj.vo.Result;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 班号信息表 前端控制器
 * </p>
 *
 * @author zwj
 * @since 2021-07-21
 */
@RestController
@RequestMapping("/class-base-info-entity")
public class ClassBaseInfoController {
    private final ClassBaseInfoService classBaseInfoService;

    public ClassBaseInfoController(ClassBaseInfoService classBaseInfoService){
        this.classBaseInfoService = classBaseInfoService;
    }


    @ApiOperation(value = "遍历所有班级", notes = "遍历所有班级")
    @GetMapping ("/selectClassBaseInfos")
    public Result selectClassBaseInfos() {
        return classBaseInfoService.selectClassBaseInfos();
    }
    @ApiOperation(value = "新增班级", notes = "新增班级")
    @PostMapping("/addClassBaseInfo")
    public Result addClassBaseInfo(@RequestBody AddClassBo addClassBo, HttpServletRequest request) {
        UserEntity userEntity = TokenUtils.getUser(request);
        return classBaseInfoService.addClassBaseInfo(addClassBo,userEntity);
    }
    @ApiOperation(value = "条件查询班级", notes = "条件查询班级")
    @PostMapping("/selectClassBaseInfo")
    public Result selectClassBaseInfo(@RequestBody SelectClassBo selectClassBo, HttpServletRequest request) {
        UserEntity userEntity = TokenUtils.getUser(request);
        return classBaseInfoService.selectClassBaseInfo(selectClassBo,userEntity);
    }
    @ApiOperation(value = "编辑班级", notes = "编辑班级")
    @PostMapping("/updateClassBaseInfo")
    public Result updateClassBaseInfo(@RequestBody UpdateClassBo updateClassBo, HttpServletRequest request) {
        UserEntity userEntity = TokenUtils.getUser(request);
        return classBaseInfoService.updateClassBaseInfo(updateClassBo,userEntity);
    }
    @ApiOperation(value = "删除班级", notes = "删除班级")
    @DeleteMapping("/deleteClassBaseInfo")
    public Result deleteClassBaseInfo(@RequestBody int id, HttpServletRequest request) {
        UserEntity userEntity = TokenUtils.getUser(request);
        return classBaseInfoService.deleteClassBaseInfo(id,userEntity);
    }
}

